package com.mgs.product.tagger.handlers
{
	import com.mgs.fwk.context.ApplicationContext;
	import com.mgs.fwk.handlers.ActionHandler;
	import com.mgs.product.tagger.controller.ContextController;
	import com.mgs.product.tagger.actions.AccessCellAction;
	import com.mgs.product.tagger.actions.ApplicationAction;
	import com.mgs.product.tagger.model.Segment;
	import com.mgs.product.tagger.ui.dto.NavigationContext;
	
	public class NextCellHandler implements ActionHandler
	{
		public function NextCellHandler()
		{
		}
		
		public function execute(context:ApplicationContext, action:ApplicationAction):void
		{
			(context as NavigationContext).history.currentIndex++;
			(context as NavigationContext).history.historyLocked = true;
			var subaction:AccessCellAction = new AccessCellAction();
			subaction.tags = ((context as NavigationContext).history.historyCells.getItemAt(
				(context as NavigationContext).history.currentIndex) as Vector.<Segment>).concat();
			ContextController.instance.processAction(context as NavigationContext, subaction);
			(context as NavigationContext).history.historyLocked = false;
		}
	}
}